﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Com.Framework.Data;
using Com.Library.DB.Popup;

namespace Com.Library.DB.Popup
{
	public class PopupModel
	{
		public static void Create(int Width, int Height, int Left, int Top, byte PopupType, string ImageURL, string LinkURL, string HTML, byte IsCookie, string ManagerName)
		{
			PopupCreateArguments arg = new PopupCreateArguments();
			arg.n4Width = Width;
			arg.n4Height = Height;
			arg.n4Left = Left;
			arg.n4Top = Top;
			arg.n1PopupType = PopupType;
			arg.strImageURL = ImageURL;
			arg.strLinkURL = LinkURL;
			arg.strHTML = HTML;
			arg.IsCookie = IsCookie;
			arg.strManagerName = ManagerName;

			PopupCreate sp = new PopupCreate();
			sp.SetArguments(arg);
			sp.ExecuteNonQuery();
		}

		public static void Modify(int SeqNo, int Width, int Height, int Left, int Top, byte PopupType, string ImageURL, string LinkURL, string HTML, byte IsCookie, string ManagerName)
		{
			PopupModifyArguments arg = new PopupModifyArguments();
			arg.n4SeqNo = SeqNo;
			arg.n4Width = Width;
			arg.n4Height = Height;
			arg.n4Left = Left;
			arg.n4Top = Top;
			arg.n1PopupType = PopupType;
			arg.strImageURL = ImageURL;
			arg.strLinkURL = LinkURL;
			arg.strHTML = HTML;
			arg.IsCookie = IsCookie;
			arg.strManagerName = ManagerName;

			PopupModify sp = new PopupModify();
			sp.SetArguments(arg);
			sp.ExecuteNonQuery();
		}

		public static void Remove(int SeqNo)
		{
			PopupRemoveArguments arg = new PopupRemoveArguments();
			arg.n4SeqNo = SeqNo;
			PopupRemove sp = new PopupRemove();
			sp.SetArguments(arg);
			sp.ExecuteNonQuery();
		}

		public static ListData<PopupEntity, OutputEntity> GetList(int PageNo, byte PageSize)
		{
			PopupGetListArguments arg = new PopupGetListArguments();
			arg.PageNo = PageNo;
			arg.PageSize = PageSize;

			PopupGetList sp = new PopupGetList();
			sp.SetArguments(arg);
			List<PopupEntity> ListData = sp.Execute();
			OutputEntity OutputData = sp.GetOutput();
			ListData<PopupEntity, OutputEntity> RetValue = new ListData<PopupEntity, OutputEntity>(ListData, OutputData);

			return RetValue;
		}

		public static PopupEntity GetInfo(int SeqNo)
		{
			PopupGetInfoArguments arg = new PopupGetInfoArguments();
			arg.n4SeqNo = SeqNo;

			PopupGetInfo sp = new PopupGetInfo();
			sp.SetArguments(arg);
			sp.ExecuteNonQuery();

			PopupEntity info = sp.GetOutput();

			return info;
		}
	}
}
